(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 12.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       158,          7]
NotebookDataLength[     12117,        316]
NotebookOptionsPosition[     10293,        280]
NotebookOutlinePosition[     10639,        295]
CellTagsIndexPosition[     10596,        292]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{

Cell[CellGroupData[{
Cell[BoxData[
 RowBox[{"basedir", "=", 
  RowBox[{"ParentDirectory", "[", 
   RowBox[{"NotebookDirectory", "[", "]"}], "]"}]}]], "Input",
 CellChangeTimes->{{3.7592569467583847`*^9, 3.7592569669784403`*^9}},
 CellLabel->"In[1]:=",ExpressionUUID->"8164aa3a-8813-4285-b161-f879f236caee"],

Cell[BoxData["\<\"D:\\\\github\\\\arnoudbuzing.github.io\"\>"], "Output",
 CellChangeTimes->{3.759256967968443*^9, 3.7592586387012644`*^9, 
  3.7602709665974236`*^9, 3.7602811566225195`*^9},
 CellLabel->"Out[1]=",ExpressionUUID->"6af32106-4193-4b8c-81b2-28221ff6a20f"]
}, Open  ]],

Cell[BoxData[
 RowBox[{"Get", "[", 
  RowBox[{"FileNameJoin", "[", 
   RowBox[{"{", 
    RowBox[{"basedir", ",", "\"\<source\>\"", ",", "\"\<template.wl\>\""}], 
    "}"}], "]"}], "]"}]], "Input",
 CellChangeTimes->{{3.7592523987352343`*^9, 3.7592524022386737`*^9}, 
   3.7592565614622903`*^9, {3.759256978587462*^9, 3.7592570003066006`*^9}},
 CellLabel->"In[2]:=",ExpressionUUID->"3aeb08c3-7018-4743-90f3-3eb0ab48d0c9"],

Cell[CellGroupData[{

Cell["build index.html", "Subsubsection",
 CellChangeTimes->{{3.759255234056806*^9, 
  3.7592552379293737`*^9}},ExpressionUUID->"0c20f902-22f9-4216-b49a-\
45516c469a40"],

Cell[BoxData[
 RowBox[{
  RowBox[{"build", "[", "file_", "]"}], ":=", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{
     "basename", ",", "basedir", ",", "notebook", ",", "webpage", ",", 
      "stream", ",", "text", ",", "data"}], "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"basename", "=", 
      RowBox[{"FileBaseName", "[", "file", "]"}]}], ";", 
     "\[IndentingNewLine]", 
     RowBox[{"basedir", "=", 
      RowBox[{"DirectoryName", "[", "file", "]"}]}], ";", 
     "\[IndentingNewLine]", 
     RowBox[{"notebook", "=", 
      RowBox[{
       RowBox[{"Import", "[", 
        RowBox[{"file", ",", "\"\<Notebook\>\""}], "]"}], "/.", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"HoldPattern", "[", "_Rule", "]"}], "\[RuleDelayed]", 
         RowBox[{"Sequence", "[", "]"}]}], "}"}]}]}], ";", 
     "\[IndentingNewLine]", 
     RowBox[{"webpage", "=", 
      RowBox[{"FileNameJoin", "[", 
       RowBox[{"{", 
        RowBox[{"basedir", ",", 
         RowBox[{"basename", "<>", "\"\<.html\>\""}]}], "}"}], "]"}]}], ";", 
     "\[IndentingNewLine]", 
     RowBox[{"DeleteFile", "[", "webpage", "]"}], ";", "\[IndentingNewLine]", 
     RowBox[{"stream", "=", 
      RowBox[{"OpenWrite", "[", "webpage", "]"}]}], ";", 
     "\[IndentingNewLine]", 
     RowBox[{"text", "=", 
      RowBox[{"First", "@", 
       RowBox[{"Cases", "[", 
        RowBox[{"notebook", ",", 
         RowBox[{
          RowBox[{"Cell", "[", 
           RowBox[{"text_String", ",", "\"\<Title\>\"", ",", "___"}], "]"}], 
          "\[RuleDelayed]", "text"}], ",", "\[Infinity]"}], "]"}]}]}], ";", 
     "\[IndentingNewLine]", 
     RowBox[{"WriteString", "[", 
      RowBox[{"stream", ",", 
       RowBox[{
        RowBox[{"template", "[", "\"\<head\>\"", "]"}], "[", 
        RowBox[{"<|", 
         RowBox[{"\"\<title\>\"", "\[Rule]", "text"}], "|>"}], "]"}]}], "]"}],
      ";", "\[IndentingNewLine]", 
     RowBox[{"WriteString", "[", 
      RowBox[{"stream", ",", 
       RowBox[{
        RowBox[{"template", "[", "\"\<h1\>\"", "]"}], "[", 
        RowBox[{"<|", 
         RowBox[{"\"\<text\>\"", "\[Rule]", "text"}], "|>"}], "]"}]}], "]"}], 
     ";", "\[IndentingNewLine]", 
     RowBox[{"text", "=", 
      RowBox[{"First", "@", 
       RowBox[{"Cases", "[", 
        RowBox[{"notebook", ",", 
         RowBox[{
          RowBox[{"Cell", "[", 
           RowBox[{"text_String", ",", "\"\<Chapter\>\"", ",", "___"}], "]"}],
           "\[RuleDelayed]", "text"}], ",", "\[Infinity]"}], "]"}]}]}], ";", 
     "\[IndentingNewLine]", 
     RowBox[{"WriteString", "[", 
      RowBox[{"stream", ",", 
       RowBox[{
        RowBox[{"template", "[", "\"\<h2\>\"", "]"}], "[", 
        RowBox[{"<|", 
         RowBox[{"\"\<text\>\"", "\[Rule]", "text"}], "|>"}], "]"}]}], "]"}], 
     ";", "\[IndentingNewLine]", 
     RowBox[{"text", "=", 
      RowBox[{"First", "@", 
       RowBox[{"Cases", "[", 
        RowBox[{"notebook", ",", 
         RowBox[{
          RowBox[{"Cell", "[", 
           RowBox[{"text_String", ",", "\"\<Subchapter\>\"", ",", "___"}], 
           "]"}], "\[RuleDelayed]", "text"}], ",", "\[Infinity]"}], "]"}]}]}],
      ";", "\[IndentingNewLine]", 
     RowBox[{"WriteString", "[", 
      RowBox[{"stream", ",", 
       RowBox[{
        RowBox[{"template", "[", "\"\<lede\>\"", "]"}], "[", 
        RowBox[{"<|", 
         RowBox[{"\"\<text\>\"", "\[Rule]", "text"}], "|>"}], "]"}]}], "]"}], 
     ";", "\[IndentingNewLine]", 
     RowBox[{"data", "=", 
      RowBox[{"Cases", "[", 
       RowBox[{"notebook", ",", 
        RowBox[{
         RowBox[{"Cell", "[", 
          RowBox[{"CellGroupData", "[", 
           RowBox[{
            RowBox[{"{", 
             RowBox[{
              RowBox[{"Cell", "[", 
               RowBox[{"caption_", ",", "\"\<Section\>\"", ",", "___"}], 
               "]"}], ",", 
              RowBox[{"Cell", "[", 
               RowBox[{"text_", ",", "\"\<Text\>\"", ",", "___"}], "]"}], ",", 
              RowBox[{"Cell", "[", 
               RowBox[{"href_", ",", "\"\<Text\>\"", ",", "___"}], "]"}]}], 
             "}"}], ",", "Open"}], "]"}], "]"}], "\[RuleDelayed]", 
         RowBox[{"<|", 
          RowBox[{
           RowBox[{"\"\<caption\>\"", "\[Rule]", "caption"}], ",", 
           RowBox[{"\"\<text\>\"", "\[Rule]", "text"}], ",", 
           RowBox[{"\"\<href\>\"", "\[Rule]", "href"}]}], "|>"}]}], ",", 
        "\[Infinity]"}], "]"}]}], ";", "\[IndentingNewLine]", 
     RowBox[{"Scan", "[", 
      RowBox[{
       RowBox[{
        RowBox[{"WriteString", "[", 
         RowBox[{"stream", ",", 
          RowBox[{
           RowBox[{"template", "[", "\"\<box\>\"", "]"}], "[", "#", "]"}]}], 
         "]"}], "&"}], ",", "data"}], "]"}], ";", "\[IndentingNewLine]", 
     RowBox[{"WriteString", "[", 
      RowBox[{"stream", ",", 
       RowBox[{"template", "[", "\"\<footer\>\"", "]"}]}], "]"}], ";", 
     "\[IndentingNewLine]", 
     RowBox[{"Close", "[", "stream", "]"}]}]}], "\[IndentingNewLine]", 
   "]"}]}]], "Input",
 CellChangeTimes->{{3.7592585911708107`*^9, 3.7592586655933266`*^9}, {
  3.7592587175294156`*^9, 3.7592589784830084`*^9}, {3.7592592566021185`*^9, 
  3.759259291215824*^9}, {3.7602750782900257`*^9, 3.760275092969084*^9}, {
  3.760281951853002*^9, 3.760281992243311*^9}},
 CellLabel->"In[37]:=",ExpressionUUID->"1dba8524-d12b-46bd-b919-547b67fa51e2"],

Cell[CellGroupData[{

Cell[BoxData[{
 RowBox[{
  RowBox[{"Echo", "[", 
   RowBox[{"build", "[", 
    RowBox[{"FileNameJoin", "[", 
     RowBox[{"{", 
      RowBox[{"basedir", ",", "\"\<index.nb\>\""}], "}"}], "]"}], "]"}], 
   "]"}], ";"}], "\n", 
 RowBox[{
  RowBox[{"files", "=", 
   RowBox[{"FileNames", "[", 
    RowBox[{"\"\<*.nb\>\"", ",", 
     RowBox[{"FileNameJoin", "[", 
      RowBox[{"{", 
       RowBox[{"basedir", ",", "\"\<wolfram\>\""}], "}"}], "]"}]}], "]"}]}], 
  ";"}], "\n", 
 RowBox[{
  RowBox[{"Map", "[", 
   RowBox[{
    RowBox[{
     RowBox[{"Echo", "[", 
      RowBox[{"build", "[", "#", "]"}], "]"}], "&"}], ",", "files"}], "]"}], 
  ";"}]}], "Input",
 CellChangeTimes->{{3.7592586256442423`*^9, 3.7592586497382975`*^9}, {
  3.7602748667223496`*^9, 3.7602748699683633`*^9}, {3.760275785592974*^9, 
  3.7602757886689777`*^9}, {3.760275837086138*^9, 3.7602758376601424`*^9}, {
  3.7602825757096643`*^9, 3.7602825923310137`*^9}},
 CellLabel->"In[41]:=",ExpressionUUID->"0f3635a7-29a7-4e66-b944-21e8baded837"],

Cell[CellGroupData[{

Cell[BoxData["\<\"D:\\\\github\\\\arnoudbuzing.github.io\\\\index.html\"\>"], \
"Echo",
 CellChangeTimes->{
  3.7602825946220617`*^9},ExpressionUUID->"09cd7631-f68d-4e21-9806-\
6a89a3a38e77"],

Cell[BoxData["\<\"D:\\\\github\\\\arnoudbuzing.github.io\\\\wolfram\\\\\
bindings.html\"\>"], "Echo",
 CellChangeTimes->{
  3.7602825947780666`*^9},ExpressionUUID->"ee115e0a-7014-4f90-9300-\
b3a5cf798ffa"],

Cell[BoxData["\<\"D:\\\\github\\\\arnoudbuzing.github.io\\\\wolfram\\\\\
communities.html\"\>"], "Echo",
 CellChangeTimes->{
  3.760282594942069*^9},ExpressionUUID->"fc05b20f-f9cb-4b24-88ff-\
0816655ea849"],

Cell[BoxData["\<\"D:\\\\github\\\\arnoudbuzing.github.io\\\\wolfram\\\\\
editors.html\"\>"], "Echo",
 CellChangeTimes->{
  3.7602825950570707`*^9},ExpressionUUID->"e11e8246-1c47-4ca5-981c-\
7a85d78d8cf2"],

Cell[BoxData["\<\"D:\\\\github\\\\arnoudbuzing.github.io\\\\wolfram\\\\github.\
html\"\>"], "Echo",
 CellChangeTimes->{
  3.760282595156073*^9},ExpressionUUID->"fe231fbe-0f93-4734-a7fb-\
80ebdfc760bb"],

Cell[BoxData["\<\"D:\\\\github\\\\arnoudbuzing.github.io\\\\wolfram\\\\index.\
html\"\>"], "Echo",
 CellChangeTimes->{
  3.7602825952650766`*^9},ExpressionUUID->"3959e117-9c8f-4b40-a5fe-\
53348470f9b9"],

Cell[BoxData["\<\"D:\\\\github\\\\arnoudbuzing.github.io\\\\wolfram\\\\\
notebooks.html\"\>"], "Echo",
 CellChangeTimes->{
  3.7602825953760777`*^9},ExpressionUUID->"af9c2696-ff93-4008-83cf-\
f071e5aad781"],

Cell[BoxData["\<\"D:\\\\github\\\\arnoudbuzing.github.io\\\\wolfram\\\\out.\
html\"\>"], "Echo",
 CellChangeTimes->{
  3.760282595521081*^9},ExpressionUUID->"8bb53b2b-9c97-4d54-86c4-\
410cab3fc076"],

Cell[BoxData["\<\"D:\\\\github\\\\arnoudbuzing.github.io\\\\wolfram\\\\\
training.html\"\>"], "Echo",
 CellChangeTimes->{
  3.76028259562708*^9},ExpressionUUID->"62afee84-7f25-49a4-bf33-c20bd4ea041e"],

Cell[BoxData["\<\"D:\\\\github\\\\arnoudbuzing.github.io\\\\wolfram\\\\videos.\
html\"\>"], "Echo",
 CellChangeTimes->{
  3.7602825957070837`*^9},ExpressionUUID->"0b8ccde5-b591-4e61-806d-\
28b2dafa3212"]
}, Open  ]]
}, Open  ]]
}, Open  ]]
},
WindowSize->{775, 872},
WindowMargins->{{25, Automatic}, {Automatic, 31}},
FrontEndVersion->"12.0 for Microsoft Windows (64-bit) (February 25, 2019)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[580, 22, 285, 5, 28, "Input",ExpressionUUID->"8164aa3a-8813-4285-b161-f879f236caee"],
Cell[868, 29, 268, 3, 32, "Output",ExpressionUUID->"6af32106-4193-4b8c-81b2-28221ff6a20f"]
}, Open  ]],
Cell[1151, 35, 420, 8, 28, "Input",ExpressionUUID->"3aeb08c3-7018-4743-90f3-3eb0ab48d0c9"],
Cell[CellGroupData[{
Cell[1596, 47, 169, 3, 44, "Subsubsection",ExpressionUUID->"0c20f902-22f9-4216-b49a-45516c469a40"],
Cell[1768, 52, 5382, 131, 447, "Input",ExpressionUUID->"1dba8524-d12b-46bd-b919-547b67fa51e2"],
Cell[CellGroupData[{
Cell[7175, 187, 1010, 27, 67, "Input",ExpressionUUID->"0f3635a7-29a7-4e66-b944-21e8baded837"],
Cell[CellGroupData[{
Cell[8210, 218, 191, 4, 23, "Echo",ExpressionUUID->"09cd7631-f68d-4e21-9806-6a89a3a38e77"],
Cell[8404, 224, 205, 4, 23, "Echo",ExpressionUUID->"ee115e0a-7014-4f90-9300-b3a5cf798ffa"],
Cell[8612, 230, 206, 4, 23, "Echo",ExpressionUUID->"fc05b20f-f9cb-4b24-88ff-0816655ea849"],
Cell[8821, 236, 204, 4, 23, "Echo",ExpressionUUID->"e11e8246-1c47-4ca5-981c-7a85d78d8cf2"],
Cell[9028, 242, 201, 4, 23, "Echo",ExpressionUUID->"fe231fbe-0f93-4734-a7fb-80ebdfc760bb"],
Cell[9232, 248, 202, 4, 23, "Echo",ExpressionUUID->"3959e117-9c8f-4b40-a5fe-53348470f9b9"],
Cell[9437, 254, 206, 4, 23, "Echo",ExpressionUUID->"af9c2696-ff93-4008-83cf-f071e5aad781"],
Cell[9646, 260, 198, 4, 23, "Echo",ExpressionUUID->"8bb53b2b-9c97-4d54-86c4-410cab3fc076"],
Cell[9847, 266, 200, 3, 23, "Echo",ExpressionUUID->"62afee84-7f25-49a4-bf33-c20bd4ea041e"],
Cell[10050, 271, 203, 4, 23, "Echo",ExpressionUUID->"0b8ccde5-b591-4e61-806d-28b2dafa3212"]
}, Open  ]]
}, Open  ]]
}, Open  ]]
}
]
*)

